package com.seagox.chat.chat.controller;

import com.seagox.chat.chat.service.IChatContactService;
import com.seagox.chat.common.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * 聊天联系人
 */
@RestController
@RequestMapping("/contact")
public class ChatContactController {

    @Autowired
    private IChatContactService chatContactService;

    /**
     * 根据用户查询联系列表
     * @param userId 用户id
     * @param name 联系人名称
     * @return
     */
    @PostMapping("/queryList")
    public ResultData queryList(String userId, String name) {
        return chatContactService.queryListByUserId(userId, name);
    }
    
    /**
     * 删除最近联系人
     */
    @PostMapping("/delete/{id}")
	public ResultData delete(@PathVariable String id, String userId, String sessionId) {
		return chatContactService.delete(id, userId, sessionId);
	}
    
    /**
     * 清除未读数
     * @param userId 用户id
     */
    @PostMapping("/cleanUnread")
    public ResultData cleanUnread(String id) {
        return chatContactService.cleanUnread(id);
    }
    
    /**
     * 发起聊天
     */
    @PostMapping("/createChat")
    public ResultData createChat(String userId, String name, String data) {
        return chatContactService.createChat(userId, name, data);
    }
    
}

